//引入express模块
const express = require("express");
//引入连接池模块
const pool = require("../pool.js");
//console.log(pool)
//创建路由器对象
const router = express.Router();
//通过用户的uid值获取用户信息的接口
//GET /me
//地址:http://127.0.0.1:3333/me
//返回结果
router.get("/:uid", (req, res, next) => {
  //1:从url获取用户的uid值

  //2:定义sql语句]
  let sql = "select * from hbb_user where uid=?";
  //3:执行数据库操作
  pool.query(sql, [req.params.uid], (err, results) => {
    if (err) {
      next(err);
      return;
    }
    res.send({ code: 200, msg: "获取用户信息成功", data: results });
  });
});
//暴露路由器对象
module.exports = router;
